package com.bipa.dao;

import com.bipa.bean.ArticleType;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface ArticleTypeDao {

    @Select("SELECT * FROM ec_article_type WHERE LENGTH(CODE) = 4")
    public List<ArticleType> findFirstTypes();

    @Select("SELECT * FROM ec_article_type  WHERE CODE LIKE #{typeCode} AND LENGTH(CODE) = 8 ")
    public List<ArticleType> findSecondTypes(@Param("typeCode") String typeCode);

    //分页查询
    @Select("select * from ec_article_type limit #{startSize},#{pageSize} ")
    public List<ArticleType> findLimit(@Param("startSize")Integer startSize,@Param("pageSize")Integer pageSize);

    @Select("select * from ec_article_type")
    public List<ArticleType> findAll();

    @Select("select * from ec_article_type where code = #{code}")
    public ArticleType findByCode(@Param("code")String code);

    @Delete("delete from ec_article_type where code = #{code}")
    public void deleteByCode(@Param("code")String code);

    @Update("update ec_article_type set name = #{name},remark = #{remark} where code = #{code}")
    public void update(ArticleType articleType);

    @Insert("insert into ec_article_type(code,name,remark) values(#{code},#{name},#{remark})")
    public void insert(ArticleType articleType);
}
